import Vue from 'vue'
import Vuex from 'vuex'
import mutations from './mutations'
import actions from './actions'

Vue.use(Vuex)

let defaultCity = '北京'
try {
  defaultCity = (localStorage.city ? localStorage.city : defaultCity)
} catch (e) {}

const store = new Vuex.Store({
  state: {
    city: defaultCity
  },
  mutations,
  getters: {
    doubleCity: function (state) {
      return state.city + ' ' + state.city
    }
  },
  actions
})

export default store
